/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __PQ_COMPONENT_H__
#define __PQ_COMPONENT_H__

#include "Object.h"

namespace PQEngine
{
	/*Component are divide into unique and ununique component.
	A unique component is a kind of component which can and only can
	attach to one game object.
	*/
	enum ComponentType
	{
		
		//Unique component
		COMPONENT_TYPE_TRANSFORM,
		COMPONENT_TYPE_MESH,
		COMPONENT_TYPE_LIGHT,

		COMPONENT_TYPE_RIGIDBODY,
		COMPONENT_TYPE_COLLIDER,//collider is a little special unique component
		
		COMPONENT_TYPE_TERRAIN,
		//Add unique component just above this line
		

		//NOT Unique component,now don't care
		//COMPONENT_TYPE_SCRIPT,

		//Add not unique component just above this line
		COMPONENT_TYPE_COUNT,
		COMPONENT_TYPE_UNKOWN,
	};

	/*A Component is a object that can extends 
	a game object's property(action) by attach to it.
	*/
	class Component
		: public Object
	{
	public:
		static Component* get(int id);
		Component(ObjectType type);
		virtual ~Component();
		
		virtual void update(float deltaT);
		void attach(GameObject *obj);
		void detach();
		
		//when compent's property changed call this to dispatch event.
		void updateProperty();
		inline ComponentType getComponentType()
		{
			return _componentType;
		}
		inline GameObject *getGameObject()
		{
			return _object;
		}
	protected:
		GameObject *_object;//which object the component belong to
		ComponentType _componentType;
	};
	class MeshComponent;
	class TransformComponent;

}
#endif
